package com.searchingmodule;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.Iterator;
import java.util.Map;
import java.util.Set;

import Neighborhood.NearestNUserNeighborhood;
import Neighborhood.Neighborhood;

import com.model.StructuredContextDataModel;
import com.recommender.StructuredContextRecommender;
import com.recommender.UserBasedRecommender;

public class TestSearchingElement {
	
	
	public static void main(String [] ar){
		
		 String datasource="picseek";
		 String url="jdbc:mysql://localhost/";
		 String username="root";
		 String password="123";
		 String driverName="com.mysql.jdbc.Driver";
		
	String tempStr="UserID:1,Keyword:doctor,Domain:medicine,Title:health,SubTitle:hospital";
	String[] temp=tempStr.trim().split(",");
	String temparry[]=null;
	HashMap<String, String> contextMap=new HashMap<String, String>();	
	
	StructuredContextRecommender recommender=new UserBasedRecommender();
	StructuredContextDataModel datamodel=new StructuredContextDataModel(datasource, url, username, password, driverName);
	Neighborhood neighborhood=new NearestNUserNeighborhood(10);
	ArrayList<String> list=new ArrayList<String>();
	list.add("UserID");
	list.add("Domain");
	list.add("Title");
	list.add("SubTitle");

	datamodel.setContextVariables(list);
	
	for(int i=0;i<temp.length;i++){
		temparry=temp[i].trim().split(":");
		contextMap.put(temparry[0],temparry[1]);
		
	}
	
	Map receivedImageResults=new HashMap<Integer, Double>();
	receivedImageResults=recommender.getRecommendations(contextMap, "doctor", 1, datamodel,neighborhood);
	

	Set set = receivedImageResults.entrySet();
	Iterator i = set.iterator();
	while(i.hasNext()) {
		Map.Entry<Integer,Double> me = (Map.Entry<Integer,Double>)i.next();
			int k=(Integer)me.getKey();
			double j=(double)me.getValue();
			System.out.println(me.getKey()+"  "+me.getValue());
	
		
	} 
	}
	

}
